package com.di

import com.hd123.stand.helper.network.NetMgr
import com.helper.network.DoctorsNetProvider
import com.sh.doctors.cloud.netconfig.DoctorsUrl
import com.sh.doctors.cloud.patient.model.local.AriticleDatabase
import com.sh.doctors.cloud.patient.model.local.dao.AriticleDao
import com.sh.doctors.cloud.patient.model.remote.AriticleService
import com.sh.doctors.cloud.patient.model.repository.AriticleRepo
import com.sh.doctors.cloud.patient.viewmodel.AriticleModel
import com.sh.doctors.cloud.patient.viewmodel.LauncherModel
import org.koin.android.ext.koin.androidApplication
import org.koin.android.viewmodel.ext.koin.viewModel
import org.koin.dsl.module.module

val viewModelModule = module {
    viewModel { LauncherModel() }
    viewModel { AriticleModel(get(), get()) }

}

//网络层接口
val remoteModule = module {
    single<AriticleService> {
        NetMgr.getRetrofit(DoctorsUrl.BASE_URL, DoctorsNetProvider()).create(AriticleService::class.java)
    }

}


//本地数据库
val localModule = module {
    single<AriticleDatabase> { AriticleDatabase.getInstance(androidApplication()) }
    single<AriticleDao> { get<AriticleDatabase>().ariticleDao() }
}

//接口调用
val repoModule = module {
    single { AriticleRepo(get(), get()) }

}

val appModule = listOf(viewModelModule, localModule, remoteModule, repoModule)